﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using NewLife;
using NewLife.Data;
using XCode;
using XCode.Cache;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace Datav.Design.Datas.Pocos;

/// <summary>用户帐号</summary>
[Serializable]
[DataObject]
[Description("用户帐号")]
[BindTable("p_user", Description = "用户帐号", ConnName = "datavdesign", DbType = DatabaseType.None)]
public partial class ProjectUser : IProjectUser, IEntity<IProjectUser>
{
    #region 属性
    private Int64 _Id;
    /// <summary>编号</summary>
    [DisplayName("编号")]
    [Description("编号")]
    [DataObjectField(true, false, false, 0)]
    [BindColumn("Id", "编号", "", DataScale = "time")]
    public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }

    private String _MobilePhone;
    /// <summary>手机号</summary>
    [DisplayName("手机号")]
    [Description("手机号")]
    [DataObjectField(false, false, false, 50)]
    [BindColumn("MobilePhone", "手机号", "", Master = true)]
    public String MobilePhone { get => _MobilePhone; set { if (OnPropertyChanging("MobilePhone", value)) { _MobilePhone = value; OnPropertyChanged("MobilePhone"); } } }

    private String _Password;
    /// <summary>密码</summary>
    [DisplayName("密码")]
    [Description("密码")]
    [DataObjectField(false, false, true, 255)]
    [BindColumn("Password", "密码", "")]
    public String Password { get => _Password; set { if (OnPropertyChanging("Password", value)) { _Password = value; OnPropertyChanged("Password"); } } }

    private String _NikeName;
    /// <summary>昵称</summary>
    [DisplayName("昵称")]
    [Description("昵称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("NikeName", "昵称", "")]
    public String NikeName { get => _NikeName; set { if (OnPropertyChanging("NikeName", value)) { _NikeName = value; OnPropertyChanged("NikeName"); } } }

    private String _RealName;
    /// <summary>真实姓名</summary>
    [DisplayName("真实姓名")]
    [Description("真实姓名")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("RealName", "真实姓名", "")]
    public String RealName { get => _RealName; set { if (OnPropertyChanging("RealName", value)) { _RealName = value; OnPropertyChanged("RealName"); } } }

    private String _PasswordSalt;
    /// <summary>秘钥</summary>
    [DisplayName("秘钥")]
    [Description("秘钥")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("PasswordSalt", "秘钥", "")]
    public String PasswordSalt { get => _PasswordSalt; set { if (OnPropertyChanging("PasswordSalt", value)) { _PasswordSalt = value; OnPropertyChanged("PasswordSalt"); } } }

    private Int32 _UserType;
    /// <summary>用户类型：1学生7普通用户</summary>
    [DisplayName("用户类型")]
    [Description("用户类型：1学生7普通用户")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("UserType", "用户类型：1学生7普通用户", "")]
    public Int32 UserType { get => _UserType; set { if (OnPropertyChanging("UserType", value)) { _UserType = value; OnPropertyChanged("UserType"); } } }

    private Int32 _Status;
    /// <summary>状态</summary>
    [DisplayName("状态")]
    [Description("状态")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("Status", "状态", "")]
    public Int32 Status { get => _Status; set { if (OnPropertyChanging("Status", value)) { _Status = value; OnPropertyChanged("Status"); } } }

    private String _PositionName;
    /// <summary>岗位名称</summary>
    [DisplayName("岗位名称")]
    [Description("岗位名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("PositionName", "岗位名称", "")]
    public String PositionName { get => _PositionName; set { if (OnPropertyChanging("PositionName", value)) { _PositionName = value; OnPropertyChanged("PositionName"); } } }

    private Int64 _ProjectId;
    /// <summary>案例Id</summary>
    [DisplayName("案例Id")]
    [Description("案例Id")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("ProjectId", "案例Id", "")]
    public Int64 ProjectId { get => _ProjectId; set { if (OnPropertyChanging("ProjectId", value)) { _ProjectId = value; OnPropertyChanged("ProjectId"); } } }

    private String _Description;
    /// <summary>详细描述</summary>
    [DisplayName("详细描述")]
    [Description("详细描述")]
    [DataObjectField(false, false, true, 1000)]
    [BindColumn("Description", "详细描述", "")]
    public String Description { get => _Description; set { if (OnPropertyChanging("Description", value)) { _Description = value; OnPropertyChanged("Description"); } } }

    private String _ClientId;
    /// <summary>客户端id</summary>
    [DisplayName("客户端id")]
    [Description("客户端id")]
    [DataObjectField(false, false, true, 36)]
    [BindColumn("ClientId", "客户端id", "")]
    public String ClientId { get => _ClientId; set { if (OnPropertyChanging("ClientId", value)) { _ClientId = value; OnPropertyChanged("ClientId"); } } }

    private Int64 _CreateBy;
    /// <summary>创建人</summary>
    [DisplayName("创建人")]
    [Description("创建人")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("CreateBy", "创建人", "")]
    public Int64 CreateBy { get => _CreateBy; set { if (OnPropertyChanging("CreateBy", value)) { _CreateBy = value; OnPropertyChanged("CreateBy"); } } }

    private Int64 _UpdateBy;
    /// <summary>修改人</summary>
    [DisplayName("修改人")]
    [Description("修改人")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("UpdateBy", "修改人", "")]
    public Int64 UpdateBy { get => _UpdateBy; set { if (OnPropertyChanging("UpdateBy", value)) { _UpdateBy = value; OnPropertyChanged("UpdateBy"); } } }

    private Int32 _IsDelete;
    /// <summary>是否删除0未删除1删除</summary>
    [DisplayName("是否删除0未删除1删除")]
    [Description("是否删除0未删除1删除")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("IsDelete", "是否删除0未删除1删除", "")]
    public Int32 IsDelete { get => _IsDelete; set { if (OnPropertyChanging("IsDelete", value)) { _IsDelete = value; OnPropertyChanged("IsDelete"); } } }

    private DateTime _CreateTime;
    /// <summary>创建时间</summary>
    [Category("扩展")]
    [DisplayName("创建时间")]
    [Description("创建时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("CreateTime", "创建时间", "")]
    public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }

    private DateTime _UpdateTime;
    /// <summary>更新时间</summary>
    [Category("扩展")]
    [DisplayName("更新时间")]
    [Description("更新时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("UpdateTime", "更新时间", "")]
    public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }

    private Int64 _TenantId;
    /// <summary>租户id</summary>
    [DisplayName("租户id")]
    [Description("租户id")]
    [DataObjectField(false, false, false, 0)]
    [BindColumn("TenantId", "租户id", "")]
    public Int64 TenantId { get => _TenantId; set { if (OnPropertyChanging("TenantId", value)) { _TenantId = value; OnPropertyChanged("TenantId"); } } }

    private DateTime _ActivationTime;
    /// <summary>激活时间</summary>
    [DisplayName("激活时间")]
    [Description("激活时间")]
    [DataObjectField(false, false, true, 0)]
    [BindColumn("ActivationTime", "激活时间", "")]
    public DateTime ActivationTime { get => _ActivationTime; set { if (OnPropertyChanging("ActivationTime", value)) { _ActivationTime = value; OnPropertyChanged("ActivationTime"); } } }

    private String _SchoolName;
    /// <summary>学校名称</summary>
    [DisplayName("学校名称")]
    [Description("学校名称")]
    [DataObjectField(false, false, true, 50)]
    [BindColumn("SchoolName", "学校名称", "")]
    public String SchoolName { get => _SchoolName; set { if (OnPropertyChanging("SchoolName", value)) { _SchoolName = value; OnPropertyChanged("SchoolName"); } } }
    #endregion

    #region 拷贝
    /// <summary>拷贝模型对象</summary>
    /// <param name="model">模型</param>
    public void Copy(IProjectUser model)
    {
        Id = model.Id;
        MobilePhone = model.MobilePhone;
        Password = model.Password;
        NikeName = model.NikeName;
        RealName = model.RealName;
        PasswordSalt = model.PasswordSalt;
        UserType = model.UserType;
        Status = model.Status;
        PositionName = model.PositionName;
        ProjectId = model.ProjectId;
        Description = model.Description;
        ClientId = model.ClientId;
        CreateBy = model.CreateBy;
        UpdateBy = model.UpdateBy;
        IsDelete = model.IsDelete;
        CreateTime = model.CreateTime;
        UpdateTime = model.UpdateTime;
        TenantId = model.TenantId;
        ActivationTime = model.ActivationTime;
        SchoolName = model.SchoolName;
    }
    #endregion

    #region 获取/设置 字段值
    /// <summary>获取/设置 字段值</summary>
    /// <param name="name">字段名</param>
    /// <returns></returns>
    public override Object this[String name]
    {
        get => name switch
        {
            "Id" => _Id,
            "MobilePhone" => _MobilePhone,
            "Password" => _Password,
            "NikeName" => _NikeName,
            "RealName" => _RealName,
            "PasswordSalt" => _PasswordSalt,
            "UserType" => _UserType,
            "Status" => _Status,
            "PositionName" => _PositionName,
            "ProjectId" => _ProjectId,
            "Description" => _Description,
            "ClientId" => _ClientId,
            "CreateBy" => _CreateBy,
            "UpdateBy" => _UpdateBy,
            "IsDelete" => _IsDelete,
            "CreateTime" => _CreateTime,
            "UpdateTime" => _UpdateTime,
            "TenantId" => _TenantId,
            "ActivationTime" => _ActivationTime,
            "SchoolName" => _SchoolName,
            _ => base[name]
        };
        set
        {
            switch (name)
            {
                case "Id": _Id = value.ToLong(); break;
                case "MobilePhone": _MobilePhone = Convert.ToString(value); break;
                case "Password": _Password = Convert.ToString(value); break;
                case "NikeName": _NikeName = Convert.ToString(value); break;
                case "RealName": _RealName = Convert.ToString(value); break;
                case "PasswordSalt": _PasswordSalt = Convert.ToString(value); break;
                case "UserType": _UserType = value.ToInt(); break;
                case "Status": _Status = value.ToInt(); break;
                case "PositionName": _PositionName = Convert.ToString(value); break;
                case "ProjectId": _ProjectId = value.ToLong(); break;
                case "Description": _Description = Convert.ToString(value); break;
                case "ClientId": _ClientId = Convert.ToString(value); break;
                case "CreateBy": _CreateBy = value.ToLong(); break;
                case "UpdateBy": _UpdateBy = value.ToLong(); break;
                case "IsDelete": _IsDelete = value.ToInt(); break;
                case "CreateTime": _CreateTime = value.ToDateTime(); break;
                case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
                case "TenantId": _TenantId = value.ToLong(); break;
                case "ActivationTime": _ActivationTime = value.ToDateTime(); break;
                case "SchoolName": _SchoolName = Convert.ToString(value); break;
                default: base[name] = value; break;
            }
        }
    }
    #endregion

    #region 关联映射
    #endregion

    #region 扩展查询
    #endregion

    #region 数据清理
    /// <summary>清理指定时间段内的数据</summary>
    /// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
    /// <param name="end">结束时间</param>
    /// <returns>清理行数</returns>
    public static Int32 DeleteWith(DateTime start, DateTime end)
    {
        return Delete(_.Id.Between(start, end, Meta.Factory.Snow));
    }
    #endregion

    #region 字段名
    /// <summary>取得用户帐号字段信息的快捷方式</summary>
    public partial class _
    {
        /// <summary>编号</summary>
        public static readonly Field Id = FindByName("Id");

        /// <summary>手机号</summary>
        public static readonly Field MobilePhone = FindByName("MobilePhone");

        /// <summary>密码</summary>
        public static readonly Field Password = FindByName("Password");

        /// <summary>昵称</summary>
        public static readonly Field NikeName = FindByName("NikeName");

        /// <summary>真实姓名</summary>
        public static readonly Field RealName = FindByName("RealName");

        /// <summary>秘钥</summary>
        public static readonly Field PasswordSalt = FindByName("PasswordSalt");

        /// <summary>用户类型：1学生7普通用户</summary>
        public static readonly Field UserType = FindByName("UserType");

        /// <summary>状态</summary>
        public static readonly Field Status = FindByName("Status");

        /// <summary>岗位名称</summary>
        public static readonly Field PositionName = FindByName("PositionName");

        /// <summary>案例Id</summary>
        public static readonly Field ProjectId = FindByName("ProjectId");

        /// <summary>详细描述</summary>
        public static readonly Field Description = FindByName("Description");

        /// <summary>客户端id</summary>
        public static readonly Field ClientId = FindByName("ClientId");

        /// <summary>创建人</summary>
        public static readonly Field CreateBy = FindByName("CreateBy");

        /// <summary>修改人</summary>
        public static readonly Field UpdateBy = FindByName("UpdateBy");

        /// <summary>是否删除0未删除1删除</summary>
        public static readonly Field IsDelete = FindByName("IsDelete");

        /// <summary>创建时间</summary>
        public static readonly Field CreateTime = FindByName("CreateTime");

        /// <summary>更新时间</summary>
        public static readonly Field UpdateTime = FindByName("UpdateTime");

        /// <summary>租户id</summary>
        public static readonly Field TenantId = FindByName("TenantId");

        /// <summary>激活时间</summary>
        public static readonly Field ActivationTime = FindByName("ActivationTime");

        /// <summary>学校名称</summary>
        public static readonly Field SchoolName = FindByName("SchoolName");

        static Field FindByName(String name) => Meta.Table.FindByName(name);
    }

    /// <summary>取得用户帐号字段名称的快捷方式</summary>
    public partial class __
    {
        /// <summary>编号</summary>
        public const String Id = "Id";

        /// <summary>手机号</summary>
        public const String MobilePhone = "MobilePhone";

        /// <summary>密码</summary>
        public const String Password = "Password";

        /// <summary>昵称</summary>
        public const String NikeName = "NikeName";

        /// <summary>真实姓名</summary>
        public const String RealName = "RealName";

        /// <summary>秘钥</summary>
        public const String PasswordSalt = "PasswordSalt";

        /// <summary>用户类型：1学生7普通用户</summary>
        public const String UserType = "UserType";

        /// <summary>状态</summary>
        public const String Status = "Status";

        /// <summary>岗位名称</summary>
        public const String PositionName = "PositionName";

        /// <summary>案例Id</summary>
        public const String ProjectId = "ProjectId";

        /// <summary>详细描述</summary>
        public const String Description = "Description";

        /// <summary>客户端id</summary>
        public const String ClientId = "ClientId";

        /// <summary>创建人</summary>
        public const String CreateBy = "CreateBy";

        /// <summary>修改人</summary>
        public const String UpdateBy = "UpdateBy";

        /// <summary>是否删除0未删除1删除</summary>
        public const String IsDelete = "IsDelete";

        /// <summary>创建时间</summary>
        public const String CreateTime = "CreateTime";

        /// <summary>更新时间</summary>
        public const String UpdateTime = "UpdateTime";

        /// <summary>租户id</summary>
        public const String TenantId = "TenantId";

        /// <summary>激活时间</summary>
        public const String ActivationTime = "ActivationTime";

        /// <summary>学校名称</summary>
        public const String SchoolName = "SchoolName";
    }
    #endregion
}
